package com.liu.usky.rlzp.uskyrlzp.controller.base;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.liu.usky.rlzp.uskyrlzp.entity.User;
import org.springframework.web.bind.annotation.ModelAttribute;

public class BaseController{
	public HttpServletRequest request;
	public HttpServletResponse reponse;

	@ModelAttribute
	public void BaseController(HttpServletRequest request,HttpServletResponse reponse) {
		this.reponse = reponse;
		this.request = request;
	}
	public BaseController() {
	}
	
	public Object getSessionObject(String key ) {
		System.out.println(request.getSession().getId());
		Object attribute = request.getSession().getAttribute(key);
		return attribute;
	}
	
	public User getSessionUser(String key) {
		Object sessionObject = getSessionObject(key);
		if(sessionObject == null) {
			return null;
		}
		return (User) sessionObject;
	}
	
	
}
